package com.shiyanlou.upms.system.controller;

import com.shiyanlou.upms.common.utils.PageUtils;
import com.shiyanlou.upms.common.utils.Query;
import com.shiyanlou.upms.system.domain.UpmsLog;
import com.shiyanlou.upms.system.service.UpmsLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/log")
public class UpmsLogController {
//@Autowired 是 Spring 框架提供的一个注解，用于自动注入依赖。当你在一个类中使用 @Autowired 注解，Spring 在初始化该类的实例时会自动查找匹配的依赖，并将其注入到对应的字段或者构造函数中。
    @Autowired
    private UpmsLogService upmsLogService;


    @GetMapping("main")
    String UpmsLog(){
        return "log/log";
    }


    @ResponseBody
    @GetMapping("/list")
    public PageUtils list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<UpmsLog> upmsLogList = upmsLogService.list(query);
        int total = upmsLogService.count(query);
        PageUtils pageUtils = new PageUtils(upmsLogList, total);
        return pageUtils;
    }
}
